using System;
using System.Collections;
using Holoville.HOTween;
using UnityEngine;

public class AnimateUpAndDown : MonoBehaviour
{
	private void Awake()
	{
		this.orgPos = base.transform.localPosition;
	}

	private void OnEnable()
	{
		if (this.seq != null)
		{
			this.seq.Kill();
		}
		base.transform.localPosition = this.orgPos;
		base.StartCoroutine("CoAnimateUpAndDown");
	}

	private void OnDisable()
	{
		if (this.seq != null)
		{
			this.seq.Kill();
		}
		base.StopCoroutine("CoAnimateUpAndDown");
	}

	private IEnumerator CoAnimateUpAndDown()
	{
		yield return new WaitForSeconds(this.delay);
		this.seq = new Sequence(new SequenceParms().Loops(-1, LoopType.Restart));
		this.seq.Insert(0f, HOTween.To(base.transform, this.duration, new TweenParms().Prop("localPosition", new Vector3(this.orgPos.x, this.orgPos.y + 0.1f, this.orgPos.z)).Ease(EaseType.EaseOutQuad)));
		this.seq.Insert(this.duration, HOTween.To(base.transform, this.duration, new TweenParms().Prop("localPosition", new Vector3(this.orgPos.x, this.orgPos.y, this.orgPos.z)).Ease(EaseType.EaseOutQuad)));
		this.seq.AppendInterval(0.1f);
		this.seq.Play();
		yield break;
	}

	public float delay;

	public float duration = 0.45f;

	private Sequence seq;

	private Vector3 orgPos;
}
